﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ChangePassword.ascx.cs" Inherits="Sites_CanNhaMoUoc_Webparts_User_ChangePassword" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<script type="text/javascript" src="<%=this._VirtualURL %>Resources/js/custom/ntthao.js"></script>
<script type="text/javascript" src="<%=this._VirtualURL %>Resources/js/custom/validator.js"></script>
<script type="text/javascript" src="<%=this._VirtualURL %>Resources/js/custom/formvalidator.js"></script>
<script type="text/javascript" src="<%=this._VirtualURL %>Resources/js/md5/md5.js"></script>
<link href="<%=this._VirtualURL %>Resources/js/hint/hint.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=this._VirtualURL %>resources/js/hint/hint.js"></script>
<style type="text/css">
td {position: relative; }
</style>

<script type="text/javascript">
function validateForm() {
    var validateResult = NTTHAO.validator.formValidationRequired();
    
    if (validateResult) {
        var txtPassword = document.getElementById("<%=txtPassword.ClientID %>");
        var encryptedPassword = document.getElementById("<%=encryptedPassword.ClientID %>");
        
        var txtOldPassword = document.getElementById("<%=txtOldPassword.ClientID %>");
        var encryptedOldPassword = document.getElementById("<%=encryptedOldPassword.ClientID %>");
        
        var md5Password = hex_md5(txtPassword.value);
        encryptedPassword.value = md5Password;
        
        var md5OldPassword = hex_md5(txtOldPassword.value);
        encryptedOldPassword.value = md5OldPassword;
        
        txtOldPassword.value = txtRetypePassword.value = txtPassword.value = "";
    }
    
    return validateResult;
}
$(document).ready(function(){
    document.getElementById('<%=txtOldPassword.ClientID %>').focus();
});
</script>
<%if(_Message != string.Empty){ %>
<div style="color: Blue; font-weight: bold; padding: 10px 30px;"><%=_Message %></div>
<%} else { %>
<form action="/trang-ca-nhan/doi-mat-khau.html" method="post" runat="server" id="aspnetForm" onsubmit="return validateForm();">
<div class="oh center" style="margin-top: 20px;">
<div class="news-title" style="text-align: center;">ĐỔI MẬT KHẨU</div>
<div class="border-round left">
<input type="hidden" id="encryptedPassword" name="encryptedPassword" value="" runat="server"/>
<input type="hidden" id="encryptedOldPassword" name="encryptedOldPassword" value="" runat="server"/>
<table cellspacing="0" cellpadding="3" border="0" align="center">
    <tr align="left">
        <td align="right">Mật khẩu cũ:</td>
        <td>
            <asp:TextBox ID="txtOldPassword" runat="server" TextMode="Password" CssClass="formInput1" minlength="6" maxlength="30"></asp:TextBox>
            <asp:CustomValidator ID="CustomValidator2" runat="server" ClientValidationFunction="NTTHAO.validator.noBlank"
                ControlToValidate="txtOldPassword" Display="Dynamic" ErrorMessage="<br />Chưa nhập mật khẩu cũ."
                ValidateEmptyText="True"></asp:CustomValidator>
        </td>
    </tr>
    <tr align="left">
        <td align="right">Mật khẩu mới:</td>
        <td>
            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="formInput1" minlength="6" maxlength="30" ></asp:TextBox>
            <asp:CustomValidator ID="CustomValidator5" runat="server" ClientValidationFunction="NTTHAO.validator.minMaxLengthRequired"
                ControlToValidate="txtPassword" Display="Dynamic" ErrorMessage="<br/>Mật khẩu đăng nhập không hợp lệ."></asp:CustomValidator>
            <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="NTTHAO.validator.noBlank"
                ControlToValidate="txtPassword" Display="Dynamic" ErrorMessage="<br />Chưa nhập mật khẩu."
                ValidateEmptyText="True"></asp:CustomValidator>
            <span class="hint">Mật khẩu phải từ 6 ký tự trở lên, có phân biệt chữ hoa/thường.<span class="hint-pointer">&nbsp;</span></span>
        </td>
    </tr>
    <tr align="left">
        <td align="right">Xác nhận mật khẩu mới:</td>
        <td>
            <asp:TextBox ID="txtRetypePassword" runat="server" TextMode="Password" CssClass="formInput1" minlength="6" maxlength="30"></asp:TextBox>
            <asp:CustomValidator ID="CustomValidator4" runat="server" ClientValidationFunction="NTTHAO.validator.noBlank"
                ControlToValidate="txtRetypePassword" Display="Dynamic" ErrorMessage="<br />Chưa xác nhận mật khẩu."
                ValidateEmptyText="True"></asp:CustomValidator>
            <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToCompare="txtPassword"
                ControlToValidate="txtRetypePassword" Display="Dynamic" ErrorMessage="<br />Mật khẩu xác nhận không đúng."></asp:CompareValidator>
        </td>
    </tr>
    <tr align="left">
        <td>&nbsp;</td>
        <td>
            <asp:Button Text="Đổi mật khẩu" ID="btnSubmit" OnClick="btnSubmit_Click" runat="server" />
        </td>
    </tr>
    <%if (_ErrorMessage != string.Empty) { %>
    <tr align="left">
        <td>&nbsp;</td>
        <td><span style="color: Red; font-weight: bold;"><%=_ErrorMessage %></span></td>
    </tr>
    <%} %>
</table>
</div>
</div>
</form>
<%} %>